package nix.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import nix.dao.LinkManDao;
import nix.domain.LinkMan;
import nix.service.LinkManService;
import nix.utils.PageBean;

public class LinkManServiceImpl implements LinkManService {

	private LinkManDao linkManDao;
	
	public void save(LinkMan linkMan) {

		linkManDao.savaOrUpdate(linkMan);
	}

	public void setLinkManDao(LinkManDao linkManDao) {
		this.linkManDao = linkManDao;
	}

	@Override
	public PageBean getPageBean(DetachedCriteria dc, Integer currentPage,
			Integer pageSize) {
		
		int totalCount = linkManDao.getTotalCount(dc);
		PageBean pb = new PageBean(currentPage, totalCount, pageSize);
		List<LinkMan> list = linkManDao.getPageList(dc, pb.getStart(), pb.getPageSize());
		pb.setList(list);
		return pb;
	}

	@Override
	public LinkMan getById(Long lkm_id) {
		return linkManDao.getById(lkm_id);
	}
}
